﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LibrarySolution.DAO.基础;

namespace LibrarySolution.Frm
{
    public partial class FrmCZ : Form
    {
        #region 属性
        YhDao yhDao;
        DataTable dt;
        private static FrmCZ Instance;
        #endregion

        #region 构造器
        public FrmCZ()
        {
            InitializeComponent();
        }
        #endregion

        #region 事件
        public static FrmCZ GetInstance()
        {
            Instance = new FrmCZ();
            Instance.bindingdata();
            return Instance;
        }

        private void CboYhNo_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (CboYhNo.Text == "")
                    SendKeys.Send("{F4}");
            }
        }

        private void FrmCZ_Load(object sender, EventArgs e)
        {
            CboYhNo.Text = "";
        }

        private void BtnCancle_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void BtnDone_Click(object sender, EventArgs e)
        {
            if (CboYhNo.Text.Trim() != "")
            {
                yhDao.Yhcz(CboYhNo.Text.Trim(),TxtCzje.Text.Trim());
                MessageBox.Show("充值成功!");
                this.Close();
            }
            else
                MessageBox.Show("请先选择用户");
        }
        #endregion

        #region 方法
        void bindingdata()
        {
            yhDao = new YhDao();
            dt = new DataTable();
            dt = yhDao.getYhNoTable();
            CboYhNo.DataSource = dt;
            CboYhNo.DisplayMember = "用户编号";
        }
        #endregion
    }
}
